<?php

namespace app\common\model;

use think\Model;
use think\model\concern\SoftDelete;
use util\Tree;

class StDept extends Model
{
    protected $name = "st_dept";

    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $defaultSoftDelete = 0;

    public function saveDeptData($data){
       $arr = [];
        foreach ($data as $key=>$val){
            $arr[$key]= $val;
            $id = self::where(['code'=>trim($val['code']),'comid'=>$val['comid']])->value('id');
            if ($id) $arr[$key]['id']=$id;
        }

        $bool =  $this->saveAll($arr);
        return $bool;
    }

}